<?php
namespace tp5_lib\bankcard\model;

use think\Model;

/**
 * 银行卡
 * @property string $id
 * @property string $user_id
 * @property string $card_id 银行卡号
 * @property string $holder 持卡人
 * @property string $bank 开户行
 * @property string $time
 * @property string $status
 */
class BankcardModel extends Model
{
    protected $table="bankcard";
    public function install()
    {
        $table=$this->db()->getTable();
        $sql="CREATE TABLE IF NOT EXISTS `$table` (
            `id` int(11) NOT NULL PRIMARY KEY AUTO_INCREMENT,
            `user_id` INT NOT NULL , 
            `card_id` VARCHAR(20) NOT NULL , 
            `holder` VARCHAR(10) NOT NULL , 
            `bank` VARCHAR(10) NOT NULL , 
            `time` INT NOT NULL , 
            `status` INT NOT NULL
        ) ENGINE=InnoDB DEFAULT CHARSET=utf8;";
        $this->db()->execute($sql);
    }
    /**
     * 检查银行卡号
     */
    public function check($no)
    {
        return preg_match("/^[0-9]{16,19}$/",$no) ? true : false ;
    }
}
